import { defineConfig } from 'vite'
import { resolve } from 'path'
import vue from '@vitejs/plugin-vue'

function pathResolve(dir) {
	return resolve(process.cwd(), '.', dir)
}
export default defineConfig({
	plugins: [vue()],
	optimizeDeps: {
		include: ['ckeditor5-custom-build/build/ckeditor']
	},
	build: {
		commonjsOptions: {
			include: ['ckeditor5-custom-build/build/ckeditor']
		}
	},
	resolve: {
		//支持别名
		alias: [
			{
				find: '@',
				replacement: pathResolve('src') + '/'
			}
		],
		dedupe: ['vue'],
		//忽略后缀
		extensions: ['.vue', '.js']
	},
	server: {
		host: '0.0.0.0',
		proxy: {
			'^/api': {
				target: 'http://192.168.1.198/',
				changeOrigin: true,
				rewrite: (path) => path.replace(/^\/api/, '')
			}
		}
	}
})
